import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 * 
 * @author andrew
 *
 */
public class SwingExample extends javax.swing.JFrame implements ActionListener{	
	protected JLabel label;
	protected JTextField textField;
	protected JButton button;
	
	/**
	 * 
	 * @param title
	 */
	public SwingExample(String title) {
		super(title);
		
		label = new JLabel("Swing Test Program");
		textField = new JTextField(); 
		button = new JButton("GO");
		
		button.addActionListener(this);
		button.setActionCommand("pressed");
		textField.addActionListener(this);
		textField.setActionCommand("pressed");
		textField.setText("Type text here");

		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		
		this.getContentPane().add(label, BorderLayout.WEST);
		this.getContentPane().add(textField, BorderLayout.CENTER);
		this.getContentPane().add(button, BorderLayout.EAST);
		this.pack();
		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		if ("pressed".equals(e.getActionCommand())) {			
			label.setText(textField.getText());
			textField.setText("");
		}
	}

	public static void main(String[] args) {
		new SwingExample("Lab 1 - SWING");
	}
}
